package fishinpool;
/**
 *
 * @author Admin
 */
public class Animal {
    Area area;
    public Hindrance hindrance;
    public Position position;
    int step;
    int age;
    public boolean checkHindrance(int x, int y, int positionX, int positionY){
        boolean hasHindrance = false;
        for(int i = 0; i < hindrance.getAmountOfHindrance(); i++){
            if(hindrance.getHindrance(i).position.x == positionX && hindrance.getHindrance(i).position.y == positionY){
                System.out.println("Hindrance");
                hasHindrance = true;
            }
        }
        return false;
    }
    public void move(){
        Direction direction = DirectionMove.selectDirection();
        switch(direction){
            case RIGHT:
                moveX(direction);
                break;
            case LEFT:
                moveX(direction);
                break;
            case UPRIGHT:
                moveUp(direction);
                break;
            case UPLEFT:
                moveUp(direction);
                break;
            case DOWNLEFT:
                moveDown(direction);
                break;
            case DOWNRIGHT:
                moveDown(direction);
                break;
        }
    }
    public void moveX(Direction direction){
        if(direction.equals(Direction.RIGHT)){
            if(this.position.x += step <= area.lenght && !isHindrance(this.position.x + step, this.position.y)){
                this.position.x += step;
            } else{
                move();
            }
        }else if(direction.equals(Direction.LEFT)){
            if(this.position.x - step >= 0 && !isHindrance(this.position.x - step, this.position.y)){
                 this.position.x -= step;
                } else {
                    move();
                }
            } 
        }

    public void moveY(Direction direction){
        if(direction.equals(Direction.UPRIGHT) || direction.equals(Direction.UPLEFT)){
            if(this.position.y + step <= area.width && !isHindrance(this.position.x, this.position.y - step)){
                this.position.y += step;
            } else {
            move();
            }
        } else if(direction.equals(Direction.DOWNLEFT) || direction.equals(Direction.UPRIGHT)){
            if(this.position.y - step >= 0 && !is Hindrance(this.position.y - step)){
                this.position.y -= step;
            } else {
            move();
            }
        }

    private boolean isHindrance(int x, int i) {
    }

    private void moveUp(Direction direction) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    private void moveDown(Direction direction) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    }
}
